{template 'public/header'}
{template 'public/comhead'}
<link rel="stylesheet" type="text/css" href="../addons/zh_yjm/template/public/ygcsslist.css">
<style type="text/css">
    .yg5_key>div{float: left;line-height: 34px;}
    .store_td1{height: 45px;}
    .store_list_img{width: 60px;height: 60px;}
    .yg5_tabel{border-color: #e5e5e5;outline: 1px solid #e5e5e5;}
    .yg5_tr2>td{padding: 10px 15px;border: 1px solid #e5e5e5;text-align:center;}
    .yg5_tr1>th{
        border: 1px solid #e5e5e5;
        padding-left: 15px;
        background-color: #FAFAFA;
        font-weight: bold;
        text-align: center;
    }
    .yg5_btn{background-color: #EEEEEE;color: #333;border: 1px solid #E4E4E4;border-radius: 6px;width: 100px;height: 34px;}
    /*#frame-2{display: block;visibility: visible;}*/
</style>
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>    
    <li class="active"><a href="javascript:void(0)">会员列表</a></li>
    <li><a href="{php echo $this->createWebUrl2('addcusmember')}">添加会员</a></li>
</ul>
<div class="main">
        <div class="panel panel-default">
            <div class="panel-body">
                <form action="" method="get" class="col-md-4">
                    <input type="hidden" name="c" value="site" />
                    <input type="hidden" name="a" value="entry" />
                    <input type="hidden" name="m" value="zh_yjm" />
                    <input type="hidden" name="do" value="cusmember" />
                    <div class="input-group" style="width: 300px">
                        <input type="text" name="keywords" class="form-control" placeholder="请输入姓名\手机号">
                        <span class="input-group-btn">
                          <input type="submit" class="btn btn-default" style="padding: 7.5px 12px" name="submit" value="查找"/>
                        </span>
                    </div>
                    <input type="hidden" name="token" value="{$_W['token']}"/>
                </form>
            </div>
        </div>
        <div class="panel panel-default ygdefault">
                
            <div class="panel-heading wyheader">
                会员管理&nbsp;>&nbsp;会员列表
            </div>
            <div class="panel-body" style="padding: 0px 15px;">

              <div class="row">
                <table class="yg5_tabel col-md-12">
                    <tr class="yg5_tr1" style="height: 50px">                   
                        <!-- <th class="col-md-1">排序</th>                     -->
                        <th class="col-md-1">会员编号</th>               
                        <th class="col-md-1">姓名/电话</th>             
                        <th class="col-md-1">余额</th>          
                        <th class="col-md-1">时间</th>
                        <th class="col-md-2">操作</th>
                    </tr>
                    {loop $cusmember $row}
                    <tr class="yg5_tr2">
                        <!-- <td>{$row['sort']}</td> -->
                        <td>{$row['number']}</td>
                        <td>{$row['name']}/{$row['phone']}</td>
                        <td>{$row['money']}</td>
                        <td>{$row['time']}</td>
                        <td>
                            <!-- {if $row['state']==1}
                            <a href="{php echo $this->createWebUrl2('cusmember', array('op' => 'hoty', 'id' => $row['id']))}"><span class="btn ygyouhui2 btn-xs" style="color:green;border:1px solid green;" id="btnx"><input type="hidden" value="{$row['id']}"><input style="border:none;background:none;" type="button" value="启用"></span></a>
                            {elseif $row['state']==0}
                            <a href="{php echo $this->createWebUrl2('cusmember', array('op' => 'hotx', 'id' => $row['id']))}"><span class="btn ygshouqian2 btn-xs" style="color:#ccc;border:1px solid #ccc;" id="btny"><input type="hidden" value="{$row['id']}"><input style="border:none;background:none;" type="button" value="禁止"></span></a>
                            {/if} -->
                            <!-- <a href="{php echo $this->createWebUrl2('addcusmember', array('id' => $row['id']))}" class="storespan btn btn-xs">
                                <span class="fa fa-pencil"></span>
                                <span class="bianji">编辑<span class="arrowdown"></span>
                                </span>
                            
                            </a> -->
                            <a href="javascript:void(0);" data-toggle="modal" data-target="#myModalb{$row['id']}"><span class="btn btn-xs ygyouhui2">充值余额</span> </a>
                            <a href="javascript:void(0);" onclick="test(this)" id="{$row['id']}" data-toggle="modal" data-target="#myModalx{$row['id']}"><span class="btn btn-xs ygshouqian2">添加消费</span></a>
                            <a href="{php echo $this->createWebUrl2('memsx', array('id' => $row['id']))}" class="storespan btn btn-xs">
                                <span class="fa fa-file-text-o"></span>
                                <span class="bianji">充值记录<span class="arrowdown"></span></span>
                            </a>
                            <a href="{php echo $this->createWebUrl2('memsxx', array('id' => $row['id']))}" class="storespan btn btn-xs">
                                <span class="fa fa-signal"></span>
                                <span class="bianji">消费记录<span class="arrowdown"></span></span>
                            </a>
                            <a href="javascript:void(0);" class="storespan btn btn-xs" data-toggle="modal" data-target="#myModal{$row['id']}">
                                <span class="fa fa-trash-o"></span>
                                <span class="bianji">删除<span class="arrowdown"></span>
                                </span>
                            </a>
                            <!-- <a class="btn btn-warning btn-xs" href="{php echo $this->createWebUrl2('addad', array('id' => $row['id']))}" title="编辑">改</a>
                            &nbsp;&nbsp;<button type="button" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#myModal{$row['id']}">删</button> -->
                        </td>
                    </tr>
                    <div class="modal fade" id="myModalb{$row['id']}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                      <div class="modal-dialog" role="document" style="min-width: 300px!important;width: 250px;">
                          <form action="" method="post" enctype="multipart/form-data">
                              <div class="modal-content">
                                  <div class="modal-header">
                                      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                      <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">充值金额</h4>
                                  </div>
                                  <div class="modal-body" style="font-size:18px">
                                    <span style="float:left;font-size:14px;line-height:32px;">收银员：</span>
                                    <select style="width:175px;" name="ass_id" id="cateid" class="form-control">
                                        {loop $assistant $rows}
                                            <option value="{$rows['id']}">{$rows['assistant']}</option>
                                        {/loop}
                                    </select>
                                  </div>
                                  <div class="modal-body" style="font-size:18px;padding-top:0px;">
                                      <span style="float:left;font-size:14px;line-height:32px;">充值金额：</span>
                                      <input style="width:160px;" type="text" name="money" class="accout_inp col-md-9" placeholder="请输入+(?)金额">
                                  </div>
                                  <div class="modal-footer">
                                      <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                      <input type="submit" name="submit2" class="btn btn-info" value="确定">
                                      <input type="hidden" name="token" value="{$_W['token']}"/>
                                      <input type="hidden" name="id" value="{$row['id']}"/>
                                  </div>
                              </div>
                          </form>
                      </div>
                    </div>
                    <div class="modal fade" id="myModalx{$row['id']}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                      <div class="modal-dialog" role="document" style="min-width: 300px!important;width: 250px;">
                          <form action="" method="post" enctype="multipart/form-data">
                              <div class="modal-content">
                                  <div class="modal-header">
                                      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                      <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">添加消费</h4>
                                  </div>
                                  <div class="modal-body" style="font-size:18px;">
                                    <span style="float:left;font-size:14px;line-height:32px;">项目类型：</span>
                                    <select style="width:145px;" name="projecttype_id"  onchange="show_sub(this.options[this.options.selectedIndex].value)" id="projecttype{$row['id']}" class="form-control">
                                        {loop $projecttype $type}
                                            <option value="{$type['id']}">{$type['title']}</option>
                                        {/loop}
                                    </select>
                                  </div>
                                  <div class="modal-body" style="font-size:18px;padding-top:0px;">
                                    <span style="float:left;font-size:14px;line-height:32px;">项目名称：</span>
                                    <select style="width:145px;" name="project_id" id="project{$row['id']}" class="form-control">
                                        {loop $project $types}
                                            <option value="{$types['id']}">{$types['project']}</option>
                                        {/loop}
                                    </select>
                                  </div>
                                  <div class="modal-body" style="font-size:18px;padding-top:0px;">
                                    <span style="float:left;font-size:14px;line-height:32px;">收银员：</span>
                                    <select style="width:175px;" name="ass_id" id="cateid" class="form-control">
                                        {loop $assistant $rows}
                                            <option value="{$rows['id']}">{$rows['assistant']}</option>
                                        {/loop}
                                    </select>
                                  </div>
                                  <div class="modal-body" style="font-size:18px;padding-top:0px;">
                                      <span style="float:left;font-size:14px;line-height:32px;">消费金额：</span>
                                      <input style="width:160px;" type="text" name="money" class="accout_inp col-md-9" placeholder="请输入消费金额">
                                  </div>
                                  <div class="modal-footer">
                                      <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                      <input type="submit" name="submit3" class="btn btn-info" value="确定">
                                      <input type="hidden" name="token" value="{$_W['token']}"/>
                                      <input type="hidden" name="id" value="{$row['id']}"/>
                                  </div>
                              </div>
                          </form>
                      </div>
                    </div>
                    <div class="modal fade" id="myModal{$row['id']}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                      <div class="modal-dialog" role="document">
                        <div class="modal-content">
                          <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">提示</h4>
                          </div>
                          <div class="modal-body" style="font-size: 20px">
                            确定删除么？
                          </div>
                          <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                <a href="{php echo $this->createWebUrl2('cusmember', array('op' => 'delete', 'id' => $row['id']))}" type="button" class="btn btn-info" >确定</a>
                          </div>
                        </div>
                      </div>
                    </div>
                    
                    {/loop}
                </table>
              </div>
            </div>
            
    {$pager}
        </div>
</div>

<script type="text/javascript">
    var protype_id
    $(function(){
        // $("#frame-14").addClass("in");
        $("#frame-1").show();
        $("#yframe-1").addClass("wyactive");
    })
    function test(element){

    console.log(element.id)
      protype_id=element.id
      console.log(protype_id)

    }
    function show_sub(v){

    console.log(v)
        $("#project"+protype_id).html("")
        $.ajax({
            type:"post",
            url:"{$_W['siteroot']}/app/index.php?i={$uniacid['uniacid']}&c=entry&do=project&m=zh_yjm",
            dataType:"json",
            data:{projecttype_id:v},
            success:function(res){  

                    console.log(res)
                    if(res.code==200){
                      for(var i=0;i<res.data.length;i++){
                        
                          $("#project"+protype_id).append("<option value='"+res.data[i].id+"'>"+res.data[i].project+"</option>").attr("selected", true);
                      }
                    }else{
                      alert('没有项目！')
                    }

            }
        })

    }
    // $("#projecttype").change(function(){
    //     console.log(123)
    //     console.log(321)
    //     var projecttype_id=$("#projecttype option:selected").val()
    //     $("#project").html("")
    //     console.log(projecttype_id)
    //     $.ajax({
    //         type:"post",
    //         url:"{$_W['siteroot']}/app/index.php?i={$uniacid['uniacid']}&c=entry&do=project&m=zh_yjm",
    //         dataType:"json",
    //         data:{projecttype_id:projecttype_id},
    //         success:function(res){  

    //                 console.log(res)
    //                 if(res.code==200){
    //                   for(var i=0;i<res.data.length;i++){
                        
    //                       $("#project").append("<option value='"+res.data[i].id+"'>"+res.data[i].project+"</option>").attr("selected", true);
    //                   }
    //                 }else{
    //                   alert('没有项目！')
    //                 }

    //         }
    //     })

    // })
</script>